<template>
    <div class="">
        <el-dialog title="管理员编辑" :visible.sync="dialog" width="30%" :before-close="dialogClose">
            <el-form ref="formData" :model="formData" label-width="100px">
				<el-form-item label="账号" prop="username">
				    <el-input type="text" v-model="formData.username" placeholder="请输入账号"></el-input>
				</el-form-item>
				<el-form-item label="密码" prop="tpass">
				    <el-input type="text" v-model="formData.tpass" placeholder="请输入密码"></el-input>
				</el-form-item>
				<el-form-item label="类型" prop="bankno">
					<el-select v-model="formData.role" style="width: 160px">
						<el-option
							v-for="item in memberType"
							:key="item.value"
							:label="item.label"
							:value="item.value">
						</el-option>
					</el-select>
				</el-form-item>		
        		<el-form-item>
        			<el-button @click="dialogClose">取 消</el-button>
        			<el-button type="primary" @click="formSubmit">确 定</el-button>
        		</el-form-item>
            </el-form>
            
        </el-dialog>
    </div>
</template>
<script>
    export default {
        data() {
			return {
				dialog: false,
				formData: {
					id: 0,
					username: '',
					tpass: '',
				},
				memberType:[{
					label:'超级管理员',
					value:1
				},{
					label:'普通管理员',
					value:0
				}]
			}
        },
		created() {
			//this.getData()
		},
		watch: {
		},
        methods: {
			dialogClose(){
				for(let i in this.formData){
					this.formData[i] = ''
				}
				this.$emit('dialogToggle')
			},
			// 保存编辑
			formSubmit() {
				this.$apiPost('Member/editData', this.formData).then(res => {
					if(res.code == 1) {
						this.$message(res.msg)
						this.$emit('getData')
						this.dialogClose()
					} else {
						this.$message(res.msg)
					}
				})
			},
        }
    };
</script>
<style scoped>
	.mselect{
		width: 100%;
	}
</style>